<html>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<head>
<!--
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
-->
    <title>3D coastline - Мини Глобус Google Earth</title>
    <!-- *** Replace the key below below with your own API key, available at http://code.google.com/apis/maps/signup.html *** -->
    <script src="http://www.google.com/jsapi?key=ABQIAAAAQSoN48j7rjZcIIA_ZoGJSRQ_2OOd3pJr2kTduwgeopUaa7SGeRQZhFrOA51woHTuA4Pf0Gm4ZMKzVA"></script>
	
    <script>
	
google.load("earth", "1");

var panoramiobf = 'http://www.panoramio.com/panoramio.kml?';
var pangiga = 'http://mw2.google.com/mw-earth-vectordb/gallery_website/en/Gigapan_Photos.kml';
var panocities = 'http://mw1.google.com/mw-earth-vectordb/dynamic/360cities/1/en/root.kmz';
var panowwp = 'http://www.worldwidepanorama.org/worldwidepanorama/wwp_all/all_of_wwp.kmz';
var panoviewat = 'http://services.google.com/earth/kmz/view_at_n.kmz';
var povertrlag = 'https://sites.google.com/site/3dcoastliner/globus/treta-laguna/Третья_лагуна.kml';
var poveraya = 'https://sites.google.com/site/3dcoastliner/globus/mys-aja/3-hr.kml';
var poveraya1 = 'https://sites.google.com/site/3dcoastliner/globus/mys-aja/P1010047.kml';
var pover06_1_DSC00374 = 'https://sites.google.com/site/3dcoastliner/globus/staticeskaa/06_1_DSC00374.kml';
var pover06_2_DSC00372 = 'https://sites.google.com/site/3dcoastliner/globus/staticeskaa/06_2_DSC00372.kml';
var pover06_3_DSC00369 = 'https://sites.google.com/site/3dcoastliner/globus/staticeskaa/06_3_DSC00369.kml';

var ge = null;

var currentKmlObjects = {
    'panoramiobf': null,
	'pangiga': null,
	'panocities': null,
    'panowwp': null,
    'panoviewat': null
  };

function init() {
  google.earth.createInstance("map3d", initCallback, failureCallback);
 }

function initCallback(object) {
  ge = object;
  ge.getWindow().setVisibility(true);
  ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
  ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, true);
  //ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
  
  f_pano = getNL(poveraya);  f_pano.setVisibility(true);
  f_pano = getNL(poveraya1);  f_pano.setVisibility(true);
  f_pano = getNL(poveraya1);  f_pano.setVisibility(true);
  //f_pano = getNL(panocities);  f_pano.setVisibility(true);
  //f_pano = getNL(panowwp);  f_pano.setVisibility(true);
  //f_pano = getNL(panoviewat);  f_pano.setVisibility(true);
  f_pano = getNL(povertrlag);  f_pano.setVisibility(true);
  f_pano = getNL(pover06_1_DSC00374);  f_pano.setVisibility(true);
  f_pano = getNL(pover06_2_DSC00372);  f_pano.setVisibility(true);
  f_pano = getNL(pover06_3_DSC00369);  f_pano.setVisibility(true);
  
  fly2cosmos();
  
  // if the page loaded with checkboxes checked, load the appropriate
    // KML files
    if (document.getElementById('kml-panocities-check').checked)
      loadKml('panocities');
    
    if (document.getElementById('kml-panowwp-check').checked)
      loadKml('panowwp');
    
    if (document.getElementById('kml-panoviewat-check').checked)
      loadKml('panoviewat');
	  
	if (document.getElementById('kml-panoramiobf-check').checked)
      loadKml('panoramiobf');
	
	if (document.getElementById('kml-pangiga-check').checked)
      loadKml('pangiga'); 
}  
 
 function failureCallback(object) {
}

function getNL(kmlURL){
  var nl = ge.createNetworkLink("");
  var link = ge.createLink("");
  link.setHref(kmlURL);
  nl.setLink(link);
  ge.getGlobe().getFeatures().appendChild(nl);
  return nl;
}

function fly2cosmos() {
  go(44.429800,33.651809,0,8000979.04,-10.52,0); 
}

function fly2aya() {
  go(44.429800,33.651809,0,1436.78,10.52,61.40); 
}

function fly2fio() {
  go(44.49989811,33.49519717,200,120,2,70); 
} 
 
 function fly2trl() {
		go(44.73362259905476,37.42945157058471, 11.88999999797014,60,-90.10515554611744,81.92955487847084); 
 }

function go(lat,lon,alt,range,heading,tilt){
        var la = ge.createLookAt('');     
        la.set(lat, lon, alt, ge.ALTITUDE_RELATIVE_TO_GROUND, heading,tilt,range);
        ge.getView().setAbstractView(la);
}
function toggleKml(file) {
    // remove the old KML object if it exists
    if (currentKmlObjects[file]) {
      ge.getFeatures().removeChild(currentKmlObjects[file]);
      currentKmlObject = null;
    }
    
    // if the checkbox is checked, fetch the KML and show it on Earth
    var kmlCheckbox = document.getElementById('kml-' + file + '-check');
    if (kmlCheckbox.checked)
      loadKml(file);
  }
  
  function loadKml(file) {
    var kmlUrl = null;
	if (file == 'panoramiobf') kmlUrl = panoramiobf ;
	if (file == 'pangiga') kmlUrl = pangiga ;
	if (file == 'panocities') kmlUrl = panocities ;
	if (file == 'panowwp') kmlUrl = panowwp ;
	if (file == 'panoviewat') kmlUrl = panoviewat ;
	
	    // fetch the KML
    google.earth.fetchKml(ge, kmlUrl, function(kmlObject) {
      // NOTE: we still have access to the 'file' variable (via JS closures)
      
      if (kmlObject) {
        // show it on Earth
        currentKmlObjects[file] = kmlObject;
        ge.getFeatures().appendChild(kmlObject);
      } else {
        // bad KML
        currentKmlObjects[file] = null;
  
        // wrap alerts in API callbacks and event handlers
        // in a setTimeout to prevent deadlock in some browsers
        setTimeout(function() {
          alert('Bad or null KML.');
        }, 0);
        
        // uncheck the box
        document.getElementById('kml-' + file + '-check').checked = '';
      }
    });
  }	
</script>
</head>
<body onload='init()' id='body'>
    <div id='map3d' style='border: 1px solid silver; height: 500px; width: 500px;'></div>
	
	<div style="text-align:left">
	<font face="verdana, sans-serif" size="1">Глобус <b>Google Earth</b><br>
	<input type="checkbox" id="kml-panoramiobf-check" onclick="toggleKml('panoramiobf');">
	<label for="kml-panoramiobf-check">Panoramio</label>, 
	<input type="checkbox" id="kml-pangiga-check" onclick="toggleKml('pangiga');">
	<label for="kml-pangiga-check">Gigapan</label>, 
	<input type="checkbox" checked id="kml-panocities-check" onclick="toggleKml('panocities');">
	<label for="kml-panocities-check">360 Cities</label>, 
	<input type="checkbox" id="kml-panowwp-check" onclick="toggleKml('panowwp');">
	<label for="kml-panowwp-check">WWP</label> (<a href="javascript:go(44.49989811,33.49519717,200,120,2,70);">Фиолент</a>), 
	<input type="checkbox" id="kml-panoviewat-check" onclick="toggleKml('panoviewat');">
	<label for="kml-panoviewat-check">ViewAt</label> (<a href="javascript:go(44.760871,37.37971,50,5000,0,75);">Утриш</a>)<br>
	PhotoOverlay-фотографии: 
	<a href="javascript:go(44.73362259905476,37.42945157058471,11.88999999797014,15,-90.10515554611744,81.92955487847084);">Третья Лагуна</a>, 
	<a href="javascript:go(44.429800,33.651809,0,1136.78,10.52,61.40);">Затерянный мир</a><br> 
	3D-модели скал: <a href="javascript:go(44.49904723,33.50834128,150,20,0,60);">Св. Явления</a>, 
	<a href="javascript:go(44.43753736,38.18510775,48.43,100,0,74.999);">Парус</a><br>
	
	</font>
	</div>
</body>
</html>
